﻿using Microsoft.AspNetCore.Builder;
using MyWeb.Extensions.ServiceExtensions.Authorization;
using MyWeb.Extensions.ServiceExtensions.Swagger;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyWeb.Extensions
{
    /// <summary>
    /// 项目中间件
    /// </summary>
    public static class ProgramMiddleware
    {
        public static void UseProgramMiddleware(this IApplicationBuilder app)
        {
            if (app == null) throw new ArgumentNullException(nameof(app));

            //app.UseSwaggerAuthorized();
            app.UseSwaggerMiddle();
            // 封装Swagger展示
            //app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("MyWeb.index.html"));

            // 允许所有跨域，CorsPolocy是在ConfigureServices方法中配置的跨域策略名称
            app.UseCors("CorsPolocy");
            // 鉴权授权中间件
            app.UseAuthorizationMiddle();

        }
    }
}
